<?php

namespace App\Http\Services;

/*用户service层*/

use App\Http\Model\Config;

class ConfigServices extends CommonServices
{
    private $config_model;


    public function __construct()
    {

        $this->config_model = new Config();
    }

    /*
     * 获取配置
     * */
    public function getConfig($type = '')
    {
        return $this->config_model->getShareGoodsConfig($type);
    }

    /*
   * 获取配置
   * */
    public function getConfigCache($type = '')
    {
    }

    //验证是否过期
    public function checkConfigDate($type, $timestamp, $date_name)
    {
        $config_date = $this->config_model->getConfigDate($type, $date_name);
        do {
            if (empty($config_date)) {
                return false;
            }
            $config_date = explode(' - ', $config_date);
            $timestamp = date('Y-m-d H:i:s', $timestamp);
            if ($timestamp > $config_date[1] || $timestamp < $config_date[0]) {
                return false;
            }
            return true;
        } while (false);

    }

    //验证是否过期
    public function checkConfigDateNew($type, $timestamp, $date_name)
    {
        $config_date = $this->config_model->getConfigDate($type, $date_name);
        if (empty($config_date)) {
            return false;
        }
        $config_date = explode(' - ', $config_date);
        $timestamp = date('Y-m-d H:i:s', $timestamp);
        if ($timestamp > $config_date[1] || $timestamp < $config_date[0]) {
            return false;
        }
        return true;

    }


}
